﻿using System.Windows;
using System.Windows.Controls;
using CharacterCreation.Contracts;
using System.Windows.Data;

namespace CharacterCreation.Controls {
   /// <summary>
   /// A statistic control
   /// </summary>
    public class StatisticControl : Control {

        /// <summary>
        /// The DisplayMode property.
        /// </summary>
        public DisplayMode DisplayMode {
            get { return (DisplayMode)GetValue(DisplayModeProperty); }
            set { SetValue(DisplayModeProperty, value); }
        }
        public static readonly DependencyProperty DisplayModeProperty =
            DependencyProperty.Register("DisplayMode", typeof(DisplayMode), typeof(StatisticControl), null);               

        static StatisticControl() {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(StatisticControl), new FrameworkPropertyMetadata(typeof(StatisticControl)));
        }
    }

    public class StatisticModeVisibilityConverter : IValueConverter {
        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) {

            DisplayMode displayMode = (DisplayMode)value;
            string aspect = parameter.ToString();

            
            if (aspect == "Score") return Visibility.Visible;
            if (aspect == "TotalXP") return Visibility.Visible;

            if (aspect == "StartingValue") {
                switch (displayMode) {
                    case DisplayMode.Compact:
                        return Visibility.Collapsed;
                    case DisplayMode.Explicite:
                        return Visibility.Collapsed;
                    case DisplayMode.Verbose:
                        return Visibility.Visible;
                }
            }

            if (aspect == "RacialBonus") {
                switch (displayMode) {
                    case DisplayMode.Compact:
                        return Visibility.Collapsed;
                    case DisplayMode.Explicite:
                        return Visibility.Collapsed;
                    case DisplayMode.Verbose:
                        return Visibility.Visible;
                }
            }

            if (aspect == "RacialXP") {
                switch (displayMode) {
                    case DisplayMode.Compact:
                        return Visibility.Collapsed;
                    case DisplayMode.Explicite:
                        return Visibility.Visible;
                    case DisplayMode.Verbose:
                        return Visibility.Visible;
                }
            }

            if (aspect == "ProfessionalXP") {
                switch (displayMode) {
                    case DisplayMode.Compact:
                        return Visibility.Collapsed;
                    case DisplayMode.Explicite:
                        return Visibility.Visible;
                    case DisplayMode.Verbose:
                        return Visibility.Visible;
                }
            }

            if (aspect == "XP") {
                switch (displayMode) {
                    case DisplayMode.Compact:
                        return Visibility.Collapsed;
                    case DisplayMode.Explicite:
                        return Visibility.Visible;
                    case DisplayMode.Verbose:
                        return Visibility.Visible;
                }
            }

            if (aspect == "MiscellaneousXP") {
                switch (displayMode) {
                    case DisplayMode.Compact:
                        return Visibility.Collapsed;
                    case DisplayMode.Explicite:
                        return Visibility.Visible;
                    case DisplayMode.Verbose:
                        return Visibility.Visible;
                }
            }

            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            throw new System.NotImplementedException();
        }
    }
}
